package com.yuxi;

/**
 * Created by yuxi on 17/1/28.
 */
public class ClassOrInstance {
    public static void main(String[] args) {
        //第一种情况test1.test3();test1.test4();
//        Test test1 = new Test();
//        Thread1 thread1 = new Thread1(test1);
//        new Thread(thread1).start();
//        new Thread(thread1).start();
        //第二种情况,test1.test3(), test2.test4()
//        Test test1 = new Test();
//        Test test2 = new Test();
//        Thread1 thread1 = new Thread1(test1);
//        Thread2 thread2 = new Thread2(test2);
//        new Thread(thread1).start();
//        new Thread(thread2).start();
        //第三种情况 test1.test1(),test2.test2()
        Test test1 = new Test();
        Test test2 = new Test();
        Thread1 thread1 = new Thread1(test1);
        Thread2 thread2 = new Thread2(test2);
        new Thread(thread1).start();
        new Thread(thread2).start();
        //第四种情况,test1.test3(),Test.test1()
//        Test test1 = new Test();
//        Thread1 thread1 = new Thread1(test1);
//        Thread2 thread2 = new Thread2();
//        new Thread(thread1).start();
//        new Thread(thread2).start();

    }

    static class Thread1 implements Runnable {
        private Test test;

        public Thread1(Test test) {
            this.test = test;
        }

        public void run() {
            test.test1();
        }
    }

    static class Thread2 implements Runnable {
        private Test test;

        public Thread2(Test test) {
            this.test = test;
        }

        public void run() {
            test.test2();
        }
    }
}
